package com.lfs.handler;

import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.handler.context.SheetWriteHandlerContext;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import org.apache.poi.ss.usermodel.Sheet;

/**
 * 单元格格式设置
 */
public class SheetWriteFormatHandler implements SheetWriteHandler {

    /**
     * 设置列宽
     * @param context 上下文
     */
    @Override
    public void afterSheetCreate(SheetWriteHandlerContext context) {
        WriteSheetHolder writeSheetHolder = context.getWriteSheetHolder();
        Sheet sheet = writeSheetHolder.getSheet();
        sheet.setColumnWidth(2, 4000);
        sheet.setColumnWidth(3, 8000);
    }
}
